#include "csingleapplication.h"
#include <QDebug>

CSingleApplication::CSingleApplication(int argc, char *argv[], const QString &key)
    :QCoreApplication(argc, argv)
{
    // Set key
    m_sharedMemory.setKey(key);

    /* Attempt to attach to shared memory */
    if (m_sharedMemory.attach())
    {
        // has existed a instance
        m_running = true;
    }
    else
    {
        // doesn't exist a instance, attempt to create a shared memory.
        if (!m_sharedMemory.create(1))
            qDebug() << "Error:" << m_sharedMemory.error();
        m_running = false;
    }
}

CSingleApplication::~CSingleApplication()
{}

